using Eno.Domain.Entity.App;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Eno.Infrastructure.Configurations;

public class AppUserConfiguration : IEntityTypeConfiguration<AppUser>
{
    public void Configure(EntityTypeBuilder<AppUser> builder)
    {
        builder.ToTable("app_users");
        builder.HasMany(u => u.Roles).WithMany(r => r.Users).UsingEntity(j => j.ToTable("app_users_roles"));
        builder.Property(u => u.DisplayName).HasMaxLength(50);
        builder.Property(u => u.Email).HasMaxLength(100);
        builder.Property(u => u.Phone).HasMaxLength(20);
    }
}